package org.ykhl.mq.commons.pusher;

import org.ykhl.mq.commons.BaseMessage;

import java.util.UUID;

/**
 * Created by Zhangkefei on 2016/1/14.
 */
public class RequestResponse extends PushMessage {
    private final String fid;
    private final String requestId;
    private final String deviceSign;

    private final String requestAppServerId;
    private final String appSecretKey ;//密钥ID
    private final String extendSet;//存放用于扩展的内容 值可以保存成jsonString
    /**
     * 用于app server端SDK生成一个查询请求
     *  @param fid 查询的服务ID
     * @param msg 查询语句内容
     *
     */
    public RequestResponse(String fid, String version, String msg, String deviceSign, String machineID) {
        super(fid, version, msg);
        this.fid = fid;
        this.deviceSign = deviceSign;
        requestId = machineID + "%&" + UUID.randomUUID().toString();
        requestAppServerId = null;
        appSecretKey = null;
        extendSet =null;
    }

    /**
     * 用于hospital sdk从原始的查询请求生成一个请求响应信息
     *
     * @param oriRequest 原始的请求消息
     * @param response 响应内容
     */
    public RequestResponse(BaseMessage oriRequest, String response) {
        super(oriRequest.getDataType(), oriRequest.getDataVersion(), response);
        this.fid = oriRequest.getFid();
        this.requestId = oriRequest.getRequestId();
        this.requestAppServerId = oriRequest.getAppServerId();
        this.deviceSign = oriRequest.getDeviceSign();
        this.appSecretKey =oriRequest.getAppSecretKey();
        this.extendSet =oriRequest.getExtendSet();
    }

    public String getFid() {
        return fid;
    }

    public String getRequestId() {
        return requestId;
    }

    /**
     * 获取该查询请求的发起方app server id, 用于医院返回响应时指定接收方
     *
     * @return 请求的发起方app server id
     */
    public String getRequestAppServerId() {
        return requestAppServerId;
    }

    public String getDeviceSign() {
        return deviceSign;
    }

    public String getAppSecretKey() {
        return appSecretKey;
    }

    public String getExtendSet() {
        return extendSet;
    }
}
